package com.ruoyi.web.controller.facilities;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.facilities.domain.TfNoisegc;
import com.ruoyi.facilities.service.ITfNoisegcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 噪声治理设施Controller
 * 
 * @author yxf
 * @date 2021-08-10
 */
@RestController
@RequestMapping("/facilities/noise")
public class TfNoisegcController extends BaseController
{
    @Autowired
    private ITfNoisegcService tfNoisegcService;

    /**
     * 查询噪声治理设施列表
     */
    @PreAuthorize("@ss.hasPermi('facilities:noise:list')")
    @GetMapping("/list")
    public TableDataInfo list(TfNoisegc tfNoisegc)
    {
        startPage();
        List<TfNoisegc> list = tfNoisegcService.selectTfNoisegcList(tfNoisegc);
        return getDataTable(list);
    }

    /**
     * 导出噪声治理设施列表
     */
    @PreAuthorize("@ss.hasPermi('facilities:noise:export')")
    @Log(title = "噪声治理设施", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TfNoisegc tfNoisegc)
    {
        List<TfNoisegc> list = tfNoisegcService.selectTfNoisegcList(tfNoisegc);
        ExcelUtil<TfNoisegc> util = new ExcelUtil<TfNoisegc>(TfNoisegc.class);
        return util.exportExcel(list, "噪声治理设施数据");
    }

    /**
     * 获取噪声治理设施详细信息
     */
    @PreAuthorize("@ss.hasPermi('facilities:noise:query')")
    @GetMapping(value = "/{nsId}")
    public AjaxResult getInfo(@PathVariable("nsId") Long nsId)
    {
        return AjaxResult.success(tfNoisegcService.selectTfNoisegcById(nsId));
    }

    /**
     * 新增噪声治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:noise:add')")
    @Log(title = "噪声治理设施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TfNoisegc tfNoisegc)
    {
        return toAjax(tfNoisegcService.insertTfNoisegc(tfNoisegc));
    }

    /**
     * 修改噪声治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:noise:edit')")
    @Log(title = "噪声治理设施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TfNoisegc tfNoisegc)
    {
        return toAjax(tfNoisegcService.updateTfNoisegc(tfNoisegc));
    }

    /**
     * 删除噪声治理设施
     */
    @PreAuthorize("@ss.hasPermi('facilities:noise:remove')")
    @Log(title = "噪声治理设施", businessType = BusinessType.DELETE)
	@DeleteMapping("/{nsIds}")
    public AjaxResult remove(@PathVariable Long[] nsIds)
    {
        return toAjax(tfNoisegcService.deleteTfNoisegcByIds(nsIds));
    }
}
